package jtk.project4.fleet.screen.updateMeterLog;

import java.awt.FlowLayout;

import jtk.project4.fleet.domain.MeterLog;
import jtk.project4.fleet.field.UpdateMeterLogField;

import nl.coderight.jazz.form.FormView;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.TableField;
import nl.coderight.jazz.form.field.TableField.AutoResizeMode;
import nl.coderight.jazz.form.field.button.PushButton;

public class UpdateMeterLogView extends FormView {
	private TableField<MeterLog> updateMeterLogTable;
	private PushButton closeButton;
	
	@Override
	protected void init() {
		createFields();
		createLayout();		
	}	
	
	private void createFields(){
		updateMeterLogTable = new TableField<MeterLog> ("meterLogs","meterLog");
		//updateMeterLogTable.setTitle ("UpdateMeterLogTable.header.table");
		updateMeterLogTable.setAutoResizeMode(AutoResizeMode.OFF);
		updateMeterLogTable.getSelectionValues();
		
		//add columns
     	updateMeterLogTable.addColumn("label.identification:","identification:");
		updateMeterLogTable.addColumn("label.location","location");
		updateMeterLogTable.addColumn("label.category","category");
		updateMeterLogTable.addColumn("label.meter1","units");
		updateMeterLogTable.addColumn("label.meter2","units2");
		updateMeterLogTable.addColumn("label.date","logDate");
		
		closeButton = new PushButton("button.close");
	}

	private void createLayout(){
		addField(createForm());
	}
	
		private GroupControl createForm(){
			GroupControl form = new GroupControl();
			form.addField(updateMeterLogTable,NORTH);
			form.addField(createButtons(), SOUTH);	
			return form;
		}
		

		
		private GroupControl createButtons(){
			GroupControl buttons = new GroupControl();
			buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
			buttons.addField(closeButton);
			return buttons;
		}
		
}
